package com.caifu.bean;

import com.caifu.util.Util;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName :PageDo
 *
 * @author :  yb
 * @description ：
 * @date : 2020-08-26 16:47
 */
@Data
public class PageDo<T> {

    private Integer currentPage;
    private Integer pageSize;
    private Integer totalCount;
    private List<T> data;
    private Integer pages;


    public PageDo(Integer currentPage, Integer pageSize, Integer pages, Integer totalCount, List<T> data) {
        this.currentPage = Util.isNull(currentPage) ? 1 : currentPage;
        this.pageSize = Util.isNull(pageSize) ? 10 : pageSize;
        this.totalCount = Util.isNull(totalCount) ? 0 : totalCount;
        this.pages = Util.isNull(pages) ? 0 : pages;
        this.data = Util.isNull(data) ? new ArrayList<>() : data;
    }

    public PageDo(Long currentPage, Long pageSize, Integer totalCount, List<T> data) {
        this.currentPage = Util.isNull(Integer.parseInt(currentPage + "")) ? 1 : Integer.parseInt(currentPage + "");
        this.pageSize = Util.isNull(Integer.parseInt(pageSize + "")) ? 10 : Integer.parseInt(pageSize + "");
        this.totalCount = Util.isNull(totalCount) ? 0 : totalCount;
        this.data = Util.isNull(data) ? new ArrayList<>() : data;
    }

    public PageDo(Integer currentPage, Integer pageSize, Integer totalCount, List<T> data) {
        this.currentPage = Util.isNull(Integer.parseInt(currentPage + "")) ? 1 : Integer.parseInt(currentPage + "");
        this.pageSize = Util.isNull(Integer.parseInt(pageSize + "")) ? 10 : Integer.parseInt(pageSize + "");
        this.totalCount = Util.isNull(totalCount) ? 0 : totalCount;
        this.data = Util.isNull(data) ? new ArrayList<>() : data;
    }
}
